package sctu.edu.java.year2016.team02.zhoujie.Day20160604.chapter10_2;

import java.util.*;

/**
 * Created by ACER on 2016/6/1.
 */
/*分别向Set集合以及List集合中添加“A”,“a”,“c”,“C”,“a”5个元素，
观察重复值“a”能否在List集合以及Set集合中成功添加。
*/
public class Compare {
    public static void main(String[] args) {
        String x1 = "A", x2 = "a", x3 = "c", x4 = "C", x5 = "a";
        List<String> list = new LinkedList<String>();
        list.add(x1);
        list.add(x2);
        list.add(x3);
        list.add(x4);
        list.add(x5);
        System.out.println("List集合中添加“A”,“a”,“c”,“C”,“a”5个元素:");
        Iterator<String> f = list.iterator();
        while (f.hasNext()) {
            System.out.println(f.next() + "");
        }
        System.out.println();
        Set<String> setlist=new HashSet<String>();
        setlist.add(x1);
        setlist.add(x2);
        setlist.add(x3);
        setlist.add(x4);
        setlist.add(x5);
        System.out.println("Set集合中添加“A”,“a”,“c”,“C”,“a”5个元素:");
        Iterator<String> s= setlist.iterator();
        while (s.hasNext()) {
            System.out.println(s.next() + "");
        }


}
}
